package com.trade.common.utils.email;

import com.trade.common.utils.AppConfigurer;

import java.io.Serializable;
import java.util.List;
import java.util.Properties;

/**
 * 邮箱实体类
 * Created with IntelliJ IDEA.
 * User: lsk
 * Date: 2017/1/13
 */
public class MailBean implements Serializable {
    public static final String ENCODEING = "UTF-8";//邮件编码
    private String mailServerHost;//服务器地址
    private String mailServerPort;//服务器端口号
    private String sender;//发件人的邮箱
    private String name;//发件人昵称
    private String username;//用户账号
    private String password;//用户账号
    private boolean validate = true;// 是否需要身份验证
    private String receiver;//收件人的邮箱
    private String subject;//主题
    private String message;//信息内容
    private List<String> attachFileNameList;//附件

    /**
     * 重写构造程式，初始化必须字段
     */
    public MailBean() { //构造方法私有化
        this.mailServerHost= AppConfigurer.getProperties("email_server_host");
        this.mailServerPort= AppConfigurer.getProperties("email_server_port");
        this.username= AppConfigurer.getProperties("email_sender");
        this.sender= AppConfigurer.getProperties("email_sender");
        this.password= AppConfigurer.getProperties("email_sender_pwd");
        this.validate = true;
        this.name="陕西云基华海信息技术有限公司";
    }

    /**
     * 获取配置信息
     * @return
     */
    public Properties getProperties() {
        Properties p = new Properties();
        p.put("mail.smtp.host", this.mailServerHost);
        p.put("mail.smtp.port", this.mailServerPort);
        p.put("mail.smtp.auth", this.validate ? "true" : "false");
        p.put("mail.smtp.user", this.sender);
        p.put("mail.smtp.pass", this.password);
        return p;
    }

    public String getMailServerHost() {
        return mailServerHost;
    }

    public String getMailServerPort() {
        return mailServerPort;
    }

    public String getSender() {
        return sender;
    }

    public String getName() {
        return name;
    }

    public String getUsername() {
        return username;
    }

    public String getPassword() {
        return password;
    }

    public boolean isValidate() {
        return validate;
    }

    public String getReceiver() {
        return receiver;
    }

    public void setReceiver(String receiver) {
        this.receiver = receiver;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public List<String> getAttachFileNameList() {
        return attachFileNameList;
    }

    public void setAttachFileNameList(List<String> attachFileNameList) {
        this.attachFileNameList = attachFileNameList;
    }
}
